package org.lex.dbq.model.service;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.lex.dbq.model.bo.DefaultDriver;
import org.lex.dbq.model.conf.Conf;
import org.lex.dbq.model.conf.ConfLoader;

public class DefaultDriversService {
	private static final DefaultDriversService INSTANCE = new DefaultDriversService();

	public static DefaultDriversService getInstance() {
		return INSTANCE;
	}

	public Set<DefaultDriver> getDrivers(String driverClass) {
		Set<DefaultDriver> set = map.get(driverClass);
		if (null == set) {
			return Collections.emptySet();
		} else {
			return set;
		}
	}

	// <driver_class, drivers>
	private Map<String, Set<DefaultDriver>> map = new HashMap<String, Set<DefaultDriver>>();

	private DefaultDriversService() {
		ConfLoader.loadDefaultDrivers(Conf.DEFAULT_DRIVERS, this.map);
	}
}
